package com.jdbc.conn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author wzm
 * @create 2023-02-23 10:03
 */
//连接mysql 1
public class Conn01 {
    public static void main(String[] args) throws Exception {
        //定义一些连接的信息
        String url = "jdbc:mysql://localhost:3306/stusys";
        String user = "root";
        String password = "123456";


        //1.注册驱动  调用Driver中静态代码块会注册驱动到管理器
        //Class.forName("com.mysql.cj.jdbc.Driver");

        //2.通过驱动管理器建立连接
        Connection conn = DriverManager.getConnection(url, user, password);

        System.out.println("conn = " + conn);
        if(conn != null){
            System.out.println("恭喜打开连接成功");
        }

    }

}
